package com.xiaoyu.lanling.feature.serverpush.event

import `in`.srain.cube.request.JsonData
import androidx.fragment.app.FragmentActivity
import com.xiaoyu.base.app.App
import com.xiaoyu.base.serverpush.event.ServerPushBaseEvent
import com.xiaoyu.lanling.common.Constant
import com.xiaoyu.lanling.feature.checkin.CheckInDialogFragment
import com.xiaoyu.lanling.feature.checkin.datamodel.CheckInInfo

class CheckInPush(jsonData: JsonData) : ServerPushBaseEvent(jsonData) {

    val checkInInfo = CheckInInfo(jsonData.optJson("checkInInfo"))

    override fun takeAction() {
        setComplete()
        val activity = (App.getInstance().topActivity as? FragmentActivity) ?: return
        if (activity.isFinishing || activity.isDestroyed) {
            return
        }
        CheckInDialogFragment.show(activity.supportFragmentManager, checkInInfo, Constant.From.PUSH)
    }
}